package com.lijing.huffmanTree;


/**
 * @Description TODO
 * @title: Node
 * @Author LiJing
 * @Date: 2021/2/2412:00 下午
 * @Version 1.0
 */
public class Node implements Comparable<Node>{
    private int value;
    Node left;
    Node right;


    public Node(int value) {
        this.value = value;
    }

    public Node() {
    }

    @Override
    public String toString() {
        return "Node{" +
                "value=" + value +
                '}';
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public Node getLeft() {
        return left;
    }

    public void setLeft(Node left) {
        this.left = left;
    }

    public Node getRight() {
        return right;
    }

    public void setRight(Node right) {
        this.right = right;
    }

    public void preOrder(){
        System.out.println(this);
        if (this.left != null) {
            this.left.preOrder();
        }
        if (this.right != null){
            this.right.preOrder();
        }
    }

    @Override
    public int compareTo(Node o) {
        return this.value-o.value;
    }
}
